#ifndef INITRAJ_HH
#define INITRAJ_HH

#include <string>
#include <vector>
#include "zuc/nml_intf/zucpos.h"
#include "config.h"
// #include "zucIniFile.hh"
#include <boost/property_tree/ini_parser.hpp>
struct FuncIOMap;

#define ZUC_MAX_TOOL_OFFSET_NUMBER MAX_TOOL_CNT
#define ZUC_MAX_USER_OFFSET_NUMBER MAX_FRAME_CNT

/* initializes traj module from ini file */
extern int iniTraj(const char* filename);

extern int initSetAboutJoint(const char* filename, int joint_num);

extern int iniSaveDHParam(int serialNum, DHParam dhParam, const char* filename);

extern int initSafetyCRC(const char* filename);

extern int iniSaveToolOffset(ZucPose toolOff, const char* filename, unsigned char method, int id, const char* name);
extern int iniSaveTCPCalibration(const unsigned char method,
                                 const unsigned char id,
                                 const unsigned char saveType,
                                 const unsigned char statusFlag,
                                 const ZucPose* cPos,
                                 const double* jntPos1,
                                 const double* jntPos2,
                                 const double* jntPos3,
                                 const double* jntPos4,
                                 const double* jntPos5,
                                 const double* jntPos6,
                                 const double* tcpError);

extern int iniSaveUserOffset(ZucPose toolOff, const char* filename, unsigned char method, int id, const char* name);
extern int iniSaveUserCalibration(const unsigned char id,
                                  const unsigned char statusFlag,
                                  const ZucPose cPos1,
                                  const ZucPose cPos2,
                                  const ZucPose cPos3,
                                  const double* jntPos1,
                                  const double* jntPos2,
                                  const double* jntPos3);
extern int iniSaveSafeAttitude(PmRpy conicalRpy,
                               double tilt,
                               double pan,
                               double deviation,
                               double deviationwarn,
                               int openEnable,
                               int autoEnable,
                               int tipChoice,
                               const char* filename);

extern int iniSavePlannerJerk(double joint_jerk, double carte_jerk, const char* filename);

extern int iniSaveToolID(int id, const char* filename);

extern int iniSaveUserFrameID(int id, const char* filename);

extern int iniSavePayload(Payload payload, const char* filename);

extern int iniSaveInstallationAngle(double* appang, const char* filename);

extern int iniSaveFuncDIMap(FuncIOMap funcIOMap, const char* filename);

extern int iniSaveFuncDOMap(FuncIOMap funcIOMap, const char* filename);

extern int iniSaveSafetyFuncDIMap(SafetyFuncDIMap sFuncDIMap, const char* filename);

extern int iniSaveSafetyFuncDOMap(SafetyFuncDOMap sFuncDOMap, const char* filename);

extern int iniSaveSafetyRobotPowerLimit(float robotPowerLimit, const char* filename);

extern int iniSaveSafetyMomentumLimit(float momentumLimit, const char* filename);

extern int iniSaveSafetyTCPVelLimit(float tcpVelLimit, const char* filename);

extern int iniSaveCabinetId(unsigned int cabid, const char* filename);

extern int iniSaveJointLimit(int jointNum, double limit, int posFlag, const char* filename);  // posFlag: 0-->neg, 1-->pos

extern int iniSaveJointMaxVel(int jointNum, double maxVel, const char* filename);

extern int iniSaveJointMaxAcc(int jointNum, double maxAcc, const char* filename);

extern int iniSaveAxisMaxVel(int axisNum, double maxVel, const char* filename);

extern int iniSaveAxisMaxAcc(int axisNum, double maxAcc, const char* filename);

extern int iniSaveAutoWork(int enable, const char* workfile, const char* filename);
extern int iniSaveOneKeySet(int autoenable, int autoprogram, const char* filename);

extern int iniSaveSerialNum(int serialNum, const char* filename);

extern int iniSaveRobotName(const char* robotName, const char* filename);

extern int iniSaveCustomPose(int type, const double* jointPos, const char* filename);

extern int iniSaveCutsomPoseTol(double jposTol, const char* filename);
extern int iniSaveHomeVel(double vel, const char* filename);
extern int iniSaveSlaveConfig(int commType, CommInfo mbComm, const char* filename);

extern int iniSaveTorqSensorMode(int mode, const char* filename);

extern int iniSaveTorqSensorBrand(int torqsensorBrand, const char* filename);

extern int iniSaveTorqSensorComm(int commType, CommInfo commCfg, const char* filename);

extern int iniSaveTorqSensorPayload(Payload, const char* filename);

extern int iniSaveToolPayload(Payload, const char* filename);

extern int iniSaveTorqueSensorSoftLimit(double* torqueSensorSoftLimit, const char* filename);

extern int iniSaveAdmittanceDragDeadZone(const double* dead_zone, const char* filename);

extern int iniSaveTorqueSensorFilter(double torqueSensorFilter, const char* filename);

extern int iniSaveAdmitCtrlConfig(double* admitCtrlConfig, const char* filename);

extern int iniSaveCompliantTypeEnable(int complinatType, int compliantEnable, const char* filename);

extern int iniSaveCollisionGmThreshold(const double* gm_threshold, const char* filename);

extern int iniSaveCollisionFilterPara(double gm_filter, const char* filename);

extern int iniSaveAdmittanceCtrlFrame(int ftFrame, const char* filename);

extern int iniSaveVelCompliantCtrl(double* velCompliantCtrl, const char* filename);

extern int iniSaveCompliantCondition(double* compliantCondition, const char* filename);

extern int iniSaveClsnSensitivity(int clsnSensitivity, const char* filename);

extern int iniSaveTorqueForwardOpt(int torqueForwardEna, const char* filename);

extern int iniSavePayloadIdentifyTrajStartPos(int trajId, JointTraj jointTraj, const char* filename);

extern int iniSavePayloadIdentifyTrajEndPos(int trajId, JointTraj jointTraj, const char* filename);

extern int iniSavePercentageModeValue(double percentage_mode_level1_val, double percentage_mode_level2_val, const char* filename);

extern int iniSavefreeButtonOpt(bool freeButtonOpt, const char* filename);

extern int iniSavefreeProgButtonOpt(bool freeButtonOpt, bool progButtonOpt, const char* filename);
extern int iniSavePointButtonOpt(bool pointButtonOpt, const char* filename);

extern int iniSaveAnalogChannelSetting(int index, int anaChnSetting, const char* filename);

extern int iniSaveDigtalChannelSetting(int index, int dgtChnSetting, const char* filename);

extern int iniSaveScriptBackupSetting(int enable, double interval, const char* filename);

extern int iniSaveBRStartVoltage(int startVoltage, const char* filename);

extern int iniSaveTioPinMode(int pinType, int mode, const char* filename);

extern int iniSaveTioRS485ChnMode(int chnId, int mode, const char* filename);

extern int iniSaveTioRS485ChnComm(int chnId, ModRtuComm rtuComm, const char* filename);

extern int iniSaveTioVoutEnable(int enable, const char* filename);

extern int iniSaveTioVoutVoltage(int voltage, const char* filename);

extern int iniSaveServoMoveFilterType(int filterType, const char* filename);

extern int iniSaveServoMoveLPFParam(double cutoffFreq, const char* filename);

extern int iniSaveServoMoveNLFParam(double vp, double ap, double jp, double vr, double ar, double jr, const char* filename);

extern int iniSaveServoMoveMMFParam(int maxSize, double ka, double kv, double kp, const char* filename);

extern int iniSaveServoMoveLAVSParam(int maxSize, double kp, const char* filename);

extern int iniChecksumPersistence(unsigned int crc, const char* filename);

extern int iniSaveIdentifyFrictionEndPos(int friction_identify_joint_index, const double* friction_identify_end_pos, const char* filename);

extern int iniSaveIdentifyFrictionStartPos(int friction_identify_joint_index, const double* friction_identify_start_pos, const char* filename);

extern int iniSaveCollisionSensitivity(const int* joint_sensitivity, const char* filename);

extern int iniSaveFrictionCompensate(const int* friction_compensate, const char* filename);

extern int iniSaveForceLimitValue(int force_limit_value, const char* filename);

extern int iniSaveCollisionDetectionEnable(int collision_detection_enable, const char* filename);

extern int iniSaveDragControlEnable(int drag_control_enable, const char* filename);

extern int iniSaveDragControlFcCompensate(const int* drag_control_fc_compensate, const char* filename);

extern int iniSaveDragControlFvCompensate(const int* drag_control_fv_compensate, const char* filename);

extern int iniSaveDragControlFilterFactor(const int* drag_control_filter_factor, const char* filename);

extern int iniSaveDragControlDitherFactor(const double* drag_control_dither_factor, const char* filename);

extern int iniEleIdentifyTraj(int robotModel, long serialNum, double* traj_para);

extern int iniLoadPayloadIdentifyTraj(int trajId, JointTraj* jointTraj);

extern int
xmlSaveSafeZone(SafeZone zone, int openEnable, int autoEnable, ZucPose currentUserOffset, SafeZone currentSafeZone, int coordinateSystemTransformation);

extern int iniSaveRobotSafety(int model,
                              int custom,
                              int lastCustom,
                              int paramType,
                              float momentumLimit,
                              float tcpVelLimit,
                              float robotPowerLimit,
                              float stopping_dist,
                              float stopping_time);

extern int iniSaveReduceSafety(int paramType, reduce_param_config reduce_params);

extern int iniSaveDragSpeedLimit(double dragSpeedLimit);

extern int iniSaveJointErrLimit(int jointNum, double err_limit);

extern int iniSetNetExceptionHandle(float timeLimit, int motType);

extern int iniSaveSimMode(int simEnable, const char* filename);

#endif
